package com.chaoyer.cynet.dao;

import com.chaoyer.cynet.entity.PostPv;
import org.apache.ibatis.annotations.*;

/**
 * Created by lwc.
 * Description:
 * Date: 2018-05-20
 * Time: 下午4:29
 */
@Mapper
public interface PostPvMapper {

    @Select("SELECT * FROM tb_pv WHERE post_id = #{id}")
    PostPv findPvByPostId(@Param("id") String postId);

    @Insert("INSERT INTO tb_pv (post_id,pv,created_at,updated_at) values (#{id},1,now(),now())")
    void addPv(@Param("id") String postId);

    @Update("UPDATE tb_pv set pv=pv+1,updated_at=now() where post_id = #{id}")
    void updatePv(@Param("id") String postId);

}
